package ogs.game.core
{
	import flash.utils.ByteArray;
	
	import mx.core.Application;
	
	import ogs.game.core.protocol.GameMsg;
	import ogs.game.core.protocol.Protocol;
	import ogs.lib.mina.core.service.IoConnector;
	import ogs.lib.mina.core.service.IoHandlerAdapter;
	
	public class GameHandler extends IoHandlerAdapter
	{
		public function GameHandler(connector:IoConnector)
		{
			super(connector);
		}
		
		override public function messageReceived(message:Object):void
		{
			var msg:GameMsg = GameMsg(msg);
			var pcode:int = msg.pcode;
			var data:Object = msg.body;
			
			switch (pcode)
			{
				case Protocol.TEST_CODE:
					(Application.application as Main).msg.text += "[" + new Date().toDateString() + "] " + data.hello + "\r\n";
					break;
				
				default:
					break;
			}

		}
	}
}